#include "ProcessPool.hpp"
#include"Task.hpp"

void Usage(string ProcessName)
{
    cout << "Usage:" << ProcessName << " process num" << endl;
}

int main(int argc, char *argv[])
{
    // 检测是否正确使用
    if (argc != 2)
    {
        Usage(argv[0]);
        return USEERROR;
    }

    int num = stoi(argv[1]); // 获得进程个数
    ProcessPool* pp = new ProcessPool(num,Work);

    // 1. 创建进程池
    pp->InitProcessPoll();
    //  2. 派发任务
    pp->DispatchTask();
    // 3. 清理进程池
    pp->ClearProcessPool();

    // delete pp;
    return 0;
}